﻿using System;
using System.Drawing;
using System.Windows.Forms;
using WinFormsCommands;
using System.Diagnostics;

namespace TorchlightModOverseer
{
	public partial class MainWindow : Form, IView
	{
		public MainWindow()
		{
			InitializeComponent();
		}

		#region Event Handlers

		private void MainWindow_MouseDown(object sender, MouseEventArgs e)
		{
			if (InDragArea(e))
			{
				Debug.WriteLine("Dragging");
				this.DragForm();
			}
		}

		private void ExitButton_MouseClick(object sender, MouseEventArgs e)
		{
			Application.Exit();
		}

		private void MinimizeButton_Click(object sender, EventArgs e)
		{
			this.Minimize();
		}
		#endregion

		private bool InDragArea(MouseEventArgs args)
		{
			return args.HitTest(new Rectangle(0, 0, 400, 65)) ||
				args.HitTest(new Rectangle(0, 0, 13, 531)) ||
				args.HitTest(new Rectangle(387, 0, 13, 531)) ||
				args.HitTest(new Rectangle(0, 515, 400, 16)) ||
				args.HitTest(new Rectangle(0, 475, 41, 56)) ||                                                                                                                                                            
				args.HitTest(new Rectangle(344, 494, 56, 37)) ||
				args.HitTest(new Rectangle(359, 475, 41, 56)) ||
				args.HitTest(new Rectangle(344, 493, 56, 38));
		}

		private void ShowView(ViewPanelBase view)
		{
			view.Top = 130;
			view.Left = 13;
			Controls.Add(view);
			view.Show();
		}

		#region IView Members

		public CommandProcessor Processor { get; set; }

		public void BindModel(object model)
		{
			throw new NotImplementedException();
		}

		#endregion
	}
}
